<script>
import config from './static/config.js'
export default {
onLaunch: function() {
    console.log('App Launch')
    
    // 每次启动都进入引导页
    uni.reLaunch({
        url: '/pages/guide/guide'
    });
    
    // 添加一个延迟检查，确保跳转执行
    setTimeout(() => {
        const pages = getCurrentPages();
        const currentPage = pages[pages.length - 1];
        if (currentPage && currentPage.route !== 'pages/guide/guide') {
            uni.reLaunch({
                url: '/pages/guide/guide'
            });
        }
    }, 100);
},
onShow: function() {
    console.log('App Show')
},
onHide: function() {
    console.log('App Hide')
},
methods: {
    // 添加下载 tabBar 图标的函数
    async downloadTabBarIcons() {
        try {
            // 创建存储下载图标路径的对象
            const downloadedIcons = {};
            
            // 使用静态图标路径
            downloadedIcons.tabbar_icon_index_normal = config.imgUrl + '/img/tabbar_icon_index_normal.png';
            downloadedIcons.tabbar_icon_index_active = config.imgUrl + '/img/tabbar_icon_index_active.png';
            downloadedIcons.tabbar_icon_recreation_normal = config.imgUrl + '/img/tabbar_icon_recreation_normal.png';
            downloadedIcons.tabbar_icon_recreation_active = config.imgUrl + '/img/tabbar_icon_recreation_active.png';
            downloadedIcons.tabbar_icon_car_normal = config.imgUrl + '/img/tabbar_icon_car_normal.png';
            downloadedIcons.tabbar_icon_car_active = config.imgUrl + '/img/tabbar_icon_car_active.png';
            downloadedIcons.tabbar_icon_mine_normal = config.imgUrl + '/img/tabbar_icon_mine_normal.png';
            downloadedIcons.tabbar_icon_mine_active = config.imgUrl + '/img/tabbar_icon_mine_active.png';
            
            // 将图标路径存储到本地
            uni.setStorageSync('downloadedIcons', downloadedIcons);
            uni.setStorageSync('tabbar_icons_downloaded', true);
            
            console.log('TabBar icons downloaded successfully');
        } catch (error) {
            console.error('Failed to download TabBar icons:', error);
        }
    },
    
    // 设置本地 tabBar 图标的方法
    setLocalTabBarIcons() {
        // 设置首页图标
        uni.setTabBarItem({
            index: 0,
            iconPath: "static/tabbar_icons/img9352118ca4c9f4a0.png",
            selectedIconPath: "static/tabbar_icons/img9357018ca4d074b0.png"
        });
        
        // 设置娱乐图标
        uni.setTabBarItem({
            index: 1,
            iconPath: "static/tabbar_icons/img9354918ca4ccdad0.png",
            selectedIconPath: "static/tabbar_icons/img9351618ca4c96800.png"
        });
        
        // 设置购物车图标
        uni.setTabBarItem({
            index: 2,
            iconPath: "static/tabbar_icons/img9351118ca4c8eee8.png",
            selectedIconPath: "static/tabbar_icons/img9356218ca4cee640.png"
        });
        
        // 设置个人中心图标
        uni.setTabBarItem({
            index: 3,
            iconPath: "static/tabbar_icons/img9350918ca4c8c7d8.png",
            selectedIconPath: "static/tabbar_icons/img9354518ca4cc9480.png"
        });
    }
}
}
</script>

<style>
/*每个页面公共css */
/* 解决小程序和app滚动条的问题 */
/* #ifdef MP-WEIXIN || APP-PLUS */
    ::-webkit-scrollbar {
        display: none;
        width: 0 !important;
        height: 0 !important;
        -webkit-appearance: none;
        background: transparent;
        color: transparent;
      }
/* #endif */

</style>